# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php81-pecl-msgpack
_extname=msgpack
pkgver=3.0.0
pkgrel=0
pkgdesc="PHP 8.1 extension provides API for communicating with MessagePack serialization - PECL"
url="https://pecl.php.net/package/msgpack"
arch="all !x86"
license="BSD-3-Clause"
_phpv=81
_php=php$_phpv
depends="$_php-session $_php-sockets"
makedepends="$_php-dev"
checkdepends="$_php-pecl-apcu"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$pkgver.tgz"
builddir="$srcdir"/$_extname-$pkgver
provides="$_php-msgpack=$pkgver-r$pkgrel" # for backward compatibility
replaces="$_php-msgpack" # for backward compatibility

install_if="php-$_extname php$_phpv"

build() {
	phpize$_phpv
	./configure --prefix=/usr --with-php-config=php-config$_phpv
	make
}

check() {
	rm -f tests/034.phpt # XFAIL https://github.com/msgpack/msgpack-php/issues/136
	rm -f tests/035.phpt # fails on ppc64le as of slow environment https://github.com/msgpack/msgpack-php/issues/123
	# Tests require session and sockets extensions which are not bundled
	local _depsdir=/usr/lib/$_php/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test PHP_TEST_SHARED_EXTENSIONS="
		-d extension=$_depsdir/apcu.so \
		-d extension=$_depsdir/session.so \
		-d extension=$_depsdir/sockets.so \
		-d extension=modules/$_extname.so" TESTS=--show-diff
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/10_$_extname.ini
}

sha512sums="
3d0c39166f64ae918375b37cad9a19b938e02df985dd3aacaa71d067535011c369cd0d218a59603a9f4c0dfc740a00b2d6aa586df06fde079428cfb61ed42f9a  php-pecl-msgpack-3.0.0.tgz
"
